package github.kawaiior.yuanchuxiuzhen.network;

import github.kawaiior.yuanchuxiuzhen.Yuanchuxiuzhen;
import github.kawaiior.yuanchuxiuzhen.network.packet.PlayerLeftClickPacket;
import github.kawaiior.yuanchuxiuzhen.network.packet.UpdateManaPacket;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;

public class NetworkRegistryHandler {
    public static SimpleChannel INSTANCE;
    private static final String VERSION = "0.1.0";
    private static int ID = 0;
    public static int nextID(){
        return ID++;
    }

    public static void registerMessage(){
        INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation(Yuanchuxiuzhen.MODID,"power"),
                ()->VERSION,
                (version)-> version.equals(VERSION),
                (version)->version.equals(VERSION));

        INSTANCE.registerMessage(nextID(), UpdateManaPacket.class, UpdateManaPacket::encode,
                UpdateManaPacket::decode, UpdateManaPacket::handlePacket);

        INSTANCE.registerMessage(nextID(), PlayerLeftClickPacket.class, PlayerLeftClickPacket::encode,
                PlayerLeftClickPacket::decode, PlayerLeftClickPacket::handlePacket);
    }

}
